
package brickroadfitness;

import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;


public class MemberProfile extends JFrame implements ActionListener
{
    private JLabel ballabel;
    private JLabel contact;
    private JLabel contactlabel;
    private JLabel datejoinedlabel;
    private JLabel firstname;
    private JLabel firstnamelabel;
    private JLabel genderlabel;
    private JLabel header;
    private JLabel id;
    private JLabel idlabel;
    private JLabel checkinlabel;
    private JLabel checkindate;
    private JButton edit;
    private JButton delete;
    private JButton checkin;
    private JButton back;
    private JButton deduct;
    private JButton add;
    private JButton debts;
    private JLabel datejoined;
    private JLabel balance;
    private JLabel lastname;
    private JLabel lastnamelabel;
    private JLabel memberProfile;
    private JLabel memexp;
    private JLabel memexplabel;
    private JPanel memprof;
    private JLabel memstatlabel;
//    private JLabel midlabel;
//    private JLabel midname;
    private JLabel addrlabel;
    private JLabel addr;
    private JRadioButton male, female, member, notmember;
    private ButtonGroup gender, memstat;
    private JOptionPane optionpane;
    private String memID;
    public PreparedStatement pstmt;
    public Statement stmt1, stmt2;
    public ResultSet rset;
    public String query1, query2;
    public int n;
    public int index = -1;
    public String key;
  
      cnd a = new cnd();

    public MemberProfile()
    {

        super("Brickroad Fitness - Member Profile");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setBackground(new Color(255, 255, 102));
        setResizable(false);
        setVisible(true);
        //setLocationRelativeTo(null);
        setForeground(new Color(255, 255, 102));
        initComponents();
    }

    public MemberProfile(String id)
    {

        super("Brickroad Fitness - Member Profile");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setBackground(new Color(255, 255, 102));
        setResizable(false);
        setVisible(true);
        //setLocationRelativeTo(null);
        setForeground(new Color(255, 255, 102));
        memID = id;
        initComponents();
    }

    public MemberProfile(String id, int index, String key)
    {

        super("Brickroad Fitness - Member Profile");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setBackground(new Color(255, 255, 102));
        setResizable(false);
        setVisible(true);
        //setLocationRelativeTo(null);
        setForeground(new Color(255, 255, 102));
        this.index = index;
        this.key = key;
        memID = id;
        initComponents();
    }

        private void initComponents() {

        header = new JLabel();
        memprof = new JPanel();
        memberProfile = new JLabel();
        idlabel = new JLabel();
        lastnamelabel = new JLabel();
        firstnamelabel = new JLabel();
    //    midlabel = new JLabel();
        addrlabel = new JLabel();
        genderlabel = new JLabel();
        memstatlabel = new JLabel();
        memexplabel = new JLabel();
        contactlabel = new JLabel();
        datejoinedlabel = new JLabel();
        checkinlabel = new JLabel();
        ballabel = new JLabel();
        id = new JLabel();
        lastname = new JLabel();
        firstname = new JLabel();
     //   midname = new JLabel();
        addr = new JLabel();
        checkindate = new JLabel();
        memexp = new JLabel();
        contact = new JLabel();
        datejoined = new JLabel();
        balance = new JLabel();
        edit = new JButton();
        delete = new JButton();
        checkin = new JButton();
        back = new JButton();
        deduct = new JButton();
        add = new JButton();
        debts = new JButton();
        optionpane = new JOptionPane();
        male = new JRadioButton();
        female = new JRadioButton();
        member = new JRadioButton();
        notmember = new JRadioButton();
        gender = new ButtonGroup();
        memstat = new ButtonGroup();

        debts.addActionListener(this);
        add.addActionListener(this);
        deduct.addActionListener(this);
        back.addActionListener(this);
        checkin.addActionListener(this);
        delete.addActionListener(this);
        edit.addActionListener(this);
        
        gender.add(male);
        gender.add(female);

        memstat.add(member);
        memstat.add(notmember);

        header.setIcon(new ImageIcon(getClass().getResource("/PRIMER.jpg"))); // NOI18N
        header.setText("Brickroad Fitness");

        memprof.setBackground(new Color(255, 255, 102));
        memprof.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0), 5));

        memberProfile.setFont(new Font("Arial", 3, 18)); // NOI18N
        memberProfile.setText("Member Profile");

        idlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        idlabel.setText("Membership ID:");

        lastnamelabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        lastnamelabel.setText("Last Name:");

        firstnamelabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        firstnamelabel.setText("First Name:");

     //   midlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
     //   midlabel.setText("Middle Name:");

        addrlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        addrlabel.setText("Address:");

        genderlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        genderlabel.setText("Gender:");

        memstatlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        memstatlabel.setText("Membership Status:");

        checkinlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        checkinlabel.setText("Date of Last Check-in:");

        memexplabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        memexplabel.setText("Membership Expiration:");

        contactlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        contactlabel.setText("Contact Details:");

        datejoinedlabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        datejoinedlabel.setText("Date Joined:");

        ballabel.setFont(new Font("Tempus Sans ITC", 1, 14)); // NOI18N
        ballabel.setText("Balance:");

        member.setBackground(new Color(255, 255, 102));
        member.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        member.setText("Member");
        member.setEnabled(false);

        notmember.setBackground(new Color(255, 255, 102));
        notmember.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        notmember.setText("Not a Member");
        notmember.setEnabled(false);

        male.setBackground(new Color(255, 255, 102));
        male.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        male.setText("Male");
        male.setEnabled(false);

        female.setBackground(new Color(255, 255, 102));
        female.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        female.setText("Female");
        female.setEnabled(false);

        id.setFont(new Font("Tahoma", 1, 14)); // NOI18N
       // id.setText("123456");

        lastname.setFont(new Font("Tahoma", 1, 14));
        firstname.setFont(new Font("Tahoma", 1, 14));
        addr.setFont(new Font("Tahoma", 1, 14));
        contact.setFont(new Font("Tahoma", 1, 14));
        datejoined.setFont(new Font("Tahoma", 1, 14));
        memexp.setFont(new Font("Tahoma", 1, 14));
        balance.setFont(new Font("Tahoma", 1, 14));

        lastname.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //lastname.setText("Lau");

        firstname.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //firstname.setText("Jamie");

       // midname.setFont(new Font("Tahoma", 1, 14)); // NOI18N
       // midname.setText("Ty");

        addr.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //addr.setText("221 New York Street Quezon City");

        male.setBackground(new Color(255, 255, 102));
        male.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        male.setText("Male");
        male.setEnabled(false);

        female.setBackground(new Color(255, 255, 102));
        female.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //female.setSelected(true);
        female.setText("Female");
        female.setEnabled(false);

        member.setBackground(new Color(255, 255, 102));
        member.setFont(new Font("Tahoma", 1, 14)); // NOI18N
       // member.setSelected(true);
        member.setText("Member");
        member.setEnabled(false);

        notmember.setBackground(new Color(255, 255, 102));
        notmember.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        notmember.setText("Not a member");
        notmember.setEnabled(false);

        memexp.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        memexp.setForeground(new Color(255, 51, 51));
        //memexp.setText("13 August 2012");

        checkindate.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        //checkindate.setText("14 August 2011");

        contact.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //contact.setText("5466582");

        datejoined.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //datejoined.setText("13 August 2011");

        balance.setFont(new Font("Tahoma", 1, 14)); // NOI18N
        //balance.setText("75 500");

        edit.setFont(new Font("Century Gothic", 1, 18)); // NOI18N
        edit.setText("EDIT");

        delete.setFont(new Font("Century Gothic", 1, 18)); // NOI18N
        delete.setText("DELETE");

        checkin.setFont(new Font("Century Gothic", 1, 18)); // NOI18N
        checkin.setText("CHECK-IN");

        back.setFont(new Font("Century Gothic", 1, 18)); // NOI18N
        back.setText("BACK");

        deduct.setFont(new Font("Century Gothic", 1, 12)); // NOI18N
        deduct.setText("DEDUCT FROM CURRENT BALANCE");

        add.setFont(new Font("Century Gothic", 1, 12)); // NOI18N
        add.setText("ADD FROM CURRENT BALANCE");

        debts.setFont(new java.awt.Font("Century Gothic", 1, 18)); // NOI18N
        debts.setText("VIEW DEBTS");

        try{
                       a.connect();
                       System.out.println(memID);
                       query1 = "SELECT * FROM member WHERE mID = "+memID;

                       stmt1 = a.con1.createStatement();
                       rset = stmt1.executeQuery(query1);
                       rset.next();

                       id.setText(memID);

                       lastname.setFont(new Font("Tahoma", 1, 14)); // NOI18N
                       lastname.setText(rset.getString("mLastname"));
                       firstname.setText(rset.getString("mFirstname"));
                       addr.setText(rset.getString("mAddress"));
                       contact.setText(rset.getString("mContact"));
                       balance.setText(rset.getString("mBalance"));
                       datejoined.setText(rset.getString("mDateJoined"));
                       memexp.setText(rset.getString("mExpiration"));

                       checkindate.setText(rset.getString("mLastCheckin"));
                       
                       if(rset.getString("mGender").equals("Male"))
                           male.setSelected(true);
                       else
                           female.setSelected(true);

                       if(rset.getString("mStatus").equals("Member"))
                           member.setSelected(true);
                       else
                           notmember.setSelected(true);
                       a.disconnect();


        }
        catch(Exception e){
        JOptionPane invalidsearchE = new JOptionPane();
        invalidsearchE.showMessageDialog(rootPane, "ERROR: " +e.getMessage());}

        GroupLayout memprofLayout = new GroupLayout(memprof);
        memprof.setLayout(memprofLayout);
        memprofLayout.setHorizontalGroup(
            memprofLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(memprofLayout.createSequentialGroup()
                .addGap(100, 100, 100)
                .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(lastnamelabel)
                    .addComponent(idlabel)
                    .addComponent(firstnamelabel)
                   // .addComponent(midlabel)
                    .addComponent(addrlabel)
                    .addComponent(genderlabel)
                    .addComponent(memstatlabel)
                    .addComponent(memexplabel)
                    .addComponent(checkinlabel)
                    .addComponent(contactlabel)
                    .addComponent(datejoinedlabel)
                    .addComponent(ballabel))
                .addGap(49, 49, 49)
                .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(memprofLayout.createSequentialGroup()
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(lastname)
                            .addComponent(id)
                            .addComponent(firstname)
                           // .addComponent(midname)
                            .addComponent(addr)
                            .addComponent(memexp)
                            .addComponent(checkindate)
                            .addComponent(contact)
                            .addComponent(datejoined)
                        .addGroup(memprofLayout.createSequentialGroup()
                        .addGroup(memprofLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(male)
                            .addComponent(member))
                        .addGap(46, 46, 46)
                        .addGroup(memprofLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(notmember)
                            .addComponent(female))))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 130, Short.MAX_VALUE)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                            .addComponent(checkin, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(debts, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(delete, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(deduct, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(add, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(edit, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(back, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(memprofLayout.createSequentialGroup()
                        .addComponent(balance)
                        .addGap(344, 344, 344)
                        .addComponent(back, GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(memprofLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(memberProfile)
                .addContainerGap(735, Short.MAX_VALUE))
        );
        memprofLayout.setVerticalGroup(
            memprofLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(memprofLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                    .addGroup(memprofLayout.createSequentialGroup()
                        .addComponent(memberProfile)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(add, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deduct, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edit, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(delete, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(checkin, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(debts, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(back, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE))                       
                    .addGroup(memprofLayout.createSequentialGroup()
                    .addGap(2, 2, 2)
                      .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(id)
                            .addComponent(idlabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(lastname)
                            .addComponent(lastnamelabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(firstname)
                            .addComponent(firstnamelabel))
                        /*.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(midname)
                            .addComponent(midlabel))*/
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(addr)
                            .addComponent(addrlabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                            .addComponent(male)
                            .addComponent(female)
                            .addComponent(genderlabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(member)
                            .addComponent(notmember)
                            .addComponent(memstatlabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(checkindate)
                            .addComponent(checkinlabel))
                /*.addGap(6, 6, 6)
                .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                    .addGroup(memprofLayout.createSequentialGroup()*/
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(memprofLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(memprofLayout.createSequentialGroup()
                                .addComponent(memexp)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                              //  .addGap(3, 3, 3)
                                .addComponent(contact)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(datejoined)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(balance))
                            .addGroup(memprofLayout.createSequentialGroup()
                                .addComponent(memexplabel)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(contactlabel)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(datejoinedlabel)
                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ballabel)))))
                                .addContainerGap(20, Short.MAX_VALUE))
        );

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(header, 0, 0, Short.MAX_VALUE)
            .addComponent(memprof, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(header)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(memprof, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }

    public void actionPerformed(ActionEvent e)
    {
        Object event = new Object();
        event = e.getSource();

        if(event == add)
        {
            dispose();
            new AddBalance(memID);
        }
        else if (event == deduct)
        {
            dispose();
            new DeductBalance(memID);
        }
        else if (event == edit)
        {
            dispose();
            System.out.println("edit");
            new EditMember(memID);
        }
        else if (event == delete)
        {
            int ans;
            ans = optionpane.showConfirmDialog(this, "Are you sure you want to delete this member?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (ans == 0)
            {
                try {
                a.connect();
                stmt1 = a.con1.createStatement();
                query1 = "UPDATE `member`" +
                        "SET `mActive` = \"" + "Inactive"+
                        "\" WHERE `mID` = " + memID;
                            stmt1.executeUpdate(query1);
                         System.out.println("Edit Successful");
                         optionpane.showMessageDialog(this, "Member deactivated.");
                         dispose();
                         new Main();
                }

                catch (Exception ex)
                {
                    optionpane.showMessageDialog(memprof, "Error copying records from member table. " + ex.getMessage());
                    System.out.println("Error copying records from member table. " + ex.getMessage());
                }
            }
        }
        else if (event == checkin)
        {
            try{
                        a.connect();
                        query1 = "SELECT * FROM member WHERE mID = "+memID;

                        stmt1 = a.con1.createStatement();
                        rset = stmt1.executeQuery(query1);
                        rset.next();
                        
                        if (rset.getString("mStatus").equals("Member"))
                        {
                            java.util.Date date = null;
                            java.sql.Timestamp timeStamp = null;
                            Calendar calendar = Calendar.getInstance();
                            calendar.setTime(new java.util.Date());
                            java.sql.Date sqlDate = new java.sql.Date(calendar.getTimeInMillis());
                            java.sql.Time sqlTime = new java.sql.Time(calendar.getTime().getTime());
                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                            date = simpleDateFormat.parse(sqlDate.toString()+" "+sqlTime.toString());
                            timeStamp = new java.sql.Timestamp(date.getTime());
                            
                        System.out.println(date);
                        stmt2 = a.con2.createStatement();
                        query2 = "UPDATE `member`" +
                        "SET `mLastCheckin` = \"" + timeStamp +
                        "\" WHERE `mID` = " + memID;
                            stmt2.executeUpdate(query2);
                         System.out.println("Edit Successful");
                         optionpane.showMessageDialog(this, "Member successfully checked-in.");
                        }
                        else
                            optionpane.showMessageDialog(this, "Client no longer a member of the gym.");
                        a.disconnect();
                        dispose();
                        new MemberProfile(memID);
                     }
                     catch(Exception z){
                             JOptionPane invalidsearchE = new JOptionPane();
                             invalidsearchE.showMessageDialog(rootPane, "ERROR: " +z.getMessage());
                             System.out.println("Error copying records from member table. " + z.getMessage());
                     }
        }
        else if (event == debts)
        {
            dispose();
            new MemberDebt(memID);
        }
        else if (event == back)
        {
            dispose();
            if (index == -1)
                new ViewMembers();
            else
                new SearchMember(index, key);
        }
    }
}